//vC[Փx̔z
let ShowPlayers = [ "Sunny", "Luna", "Star" ];
let ShowDifficults = [ "Easy", "Normal", "Panic" ];
let ShowPlayerShowNames = [ "Tj[~N", "i`Ch", "X^[Tt@CA" ];
let ShowDifficultShowNames = [ "Easy", "Normal", "Panic" ];

//ݕ\ĂvC[ՓxCfbNX
let ShowPlayerIndex = 0;
let ShowDifficultIndex = 0;

//ݕ\ĂvC[Փx
let ShowPlayer = ShowPlayers[ ShowPlayerIndex ];
let ShowDifficult = ShowDifficults[ ShowDifficultIndex ];

//Ug\ݒ
//  0:Ugł͂Ȃ
//  1:XRAꗗ
//  2:XyJ
let ResultMode = 0;

//XyJ̌݃y[W
let SpellResultPage = 0;
//XyJ̍őy[W
let SpellResultMaxPage = 2;
//̃XyJ
let UnSeenSpellName = "HHHHHHHHHHHHHHHHHH";

/**
 * Ugʂ̕`
 */
function ResultDraw(){
	//`ʒuߗp
	let x = 0;
	let y = 0;
	//l擾p
	let no = 0;
	//擾p
	let str = "";
	
	//vC[\
	DrawText( "vC[F"                        ,  60, 40, 16, 255 );
	DrawText( ShowPlayerShowNames[ ShowPlayerIndex ], 160, 40, 16, 255 );
	
	//Փx\
	DrawText( "Փx@@F"                              ,  60, 60, 16, 255 );
	DrawText( ShowDifficultShowNames[ ShowDifficultIndex ], 160, 60, 16, 255 );
	
	if( ResultMode == 1 ){
		//XRAꗗ
		
		//f[^邽߂̕ϐ
		let score = "";
		let ns_hiscore = ShowPlayer ~ "HiScore" ~ ShowDifficult;
		let ns_playNum = ShowPlayer ~ "PlayNum" ~ ShowDifficult;
		let ns_ctClearNum = ShowPlayer ~ "ClearNum";
		let ns_ncClearNum = ShowPlayer ~ "NoContinueClearNum";
		let hiscore1 = 0;
		let hiscore2 = 0;
		let hiscore3 = 0;
		
		//nCXRA
		DrawText( "nCXRA", 180, 90, 16, 255 );
		
		ascent( i in 0..5 ){
			y = 120 + i * 20;
			no = (i + 1);
			str = IntToString( no );
			
			hiscore1 = GetCommonDataDefaultEx( "OFT_Save", ns_hiscore ~ str ~ "_1", 0 );
			hiscore2 = GetCommonDataDefaultEx( "OFT_Save", ns_hiscore ~ str ~ "_2", 0 );
			hiscore3 = GetCommonDataDefaultEx( "OFT_Save", ns_hiscore ~ str ~ "_3", 0 );
			score = LPad( SetComma( ScoreToString( hiscore1, hiscore2, hiscore3 ), 4, ",", "back" ), 26, " " );
			
			DrawText( str  ,  80, y, 16, 255 );
			DrawText( score, 110, y, 16, 255 );
		}
		
		//vCf[^
		DrawText( "vCf[^", 170, 230, 16, 255 );
		
		//Xe[WvC
		let playNum_1  = GetCommonDataDefaultEx( "OFT_Save", ns_playNum ~ "1", 0 );
		let playNum_2  = GetCommonDataDefaultEx( "OFT_Save", ns_playNum ~ "2", 0 );
		let playNum_3  = GetCommonDataDefaultEx( "OFT_Save", ns_playNum ~ "3", 0 );
		let playNum_EX = GetCommonDataDefaultEx( "OFT_Save", ns_playNum ~ "4", 0 );
		
		let clearNum_CT = GetCommonDataDefaultEx( "OFT_Save", ns_ctClearNum, 0 );
		let clearNum_NC = GetCommonDataDefaultEx( "OFT_Save", ns_ncClearNum, 0 );
		
		//Xe[W
		DrawText( "vC",                               60, 250, 16, 255 );
		DrawText( "1",                                        60, 270, 16, 255 );
		DrawText( LPad( IntToString( playNum_1 ), 5, " " ),  100, 270, 16, 255 );
		DrawText( "2",                                        60, 290, 16, 255 );
		DrawText( LPad( IntToString( playNum_2 ), 5, " " ),  100, 290, 16, 255 );
		DrawText( "3",                                        60, 310, 16, 255 );
		DrawText( LPad( IntToString( playNum_3 ), 5, " " ),  100, 310, 16, 255 );
		DrawText( "EX",                                       60, 330, 16, 255 );
		DrawText( LPad( IntToString( playNum_EX ), 5, " " ), 100, 330, 16, 255 );
		
		//NA
		DrawText( "NA",                               200, 250, 16, 255 );
		DrawText( LPad( IntToString( clearNum_CT ), 5, " " ), 200, 270, 16, 255 );
		DrawText( "m[ReBj[",                       200, 290, 16, 255 );
		DrawText( "NA",                               200, 310, 16, 255 );
		DrawText( LPad( IntToString( clearNum_NC ), 5, " " ), 200, 330, 16, 255 );
		
		//̑f[^
		DrawText( "̑f[^", 164, 360, 16, 255 );
		
		//vC
		DrawText( "vC"                             , 120, 390, 16, 255 );
		DrawText( LPad( IntToString( PlayTime_H ), 3, "0" ), 220, 390, 16, 255 );
		DrawText( ":"                                      , 250, 390, 16, 255 );
		DrawText( LPad( IntToString( PlayTime_M ), 2, "0" ), 260, 390, 16, 255 );
		DrawText( ":"                                      , 280, 390, 16, 255 );
		DrawText( LPad( IntToString( PlayTime_S ), 2, "0" ), 290, 390, 16, 255 );
		
		//
		DrawText( "㉺L[œՓx̑IAEL[ŃLN^[̑I",     40, 420, 12, 255 );
		DrawText( "VbgL[ŃXyJֈړA{L[Ńj[֖߂", 40, 440, 12, 255 );
	}else if( ResultMode == 2 ){
		//XyJ
		
		//f[^邽߂̕ϐ
		let spellCP = [ 0, 0 ];
		let spellC = 0;
		let spellP = 0;
		let spellName = "";
		
		//y[W
		DrawText( IntToString( SpellResultPage + 1 ), 360, 80, 16, 255 );
		DrawText( "/"                               , 380, 80, 16, 255 );
		DrawText( IntToString( SpellResultMaxPage ) , 400, 80, 16, 255 );
		
		//XyJ[h
		DrawText( "XyJ[h", 180, 90, 16, 255 );
		
		//XyJ
		ascent( i in 0..10 ){
			y = 140 + i * 20;
			no = (i + 1) + SpellResultPage * 10;
			str = IntToString( no );
			spellCP = GetSpellData( ShowPlayer, ShowDifficult, str );
			spellC = spellCP[ 0 ];
			spellP = spellCP[ 1 ];
			if( spellP == 0 ){
				spellName = UnSeenSpellName;
			}else{
				spellName = GetSpellName( ShowPlayer, ShowDifficult, str );
			}
			
			//擾Xyɂ́
			if( spellC > 0 ){
				DrawText( ""                         ,  40, y, 12, 255 );
			}
			DrawText( "No."                                ,  60, y, 12, 255 );
			DrawText( LPad( str, 2, "0" )                  ,  80, y, 12, 255 );
			DrawText( spellName                            , 104, y, 12, 255 );
			DrawText( LPad( IntToString( spellC ), 3, "0" ), 347, y, 12, 255 );
			DrawText( "/"                                  , 372, y, 12, 255 );
			DrawText( LPad( IntToString( spellP ), 3, "0" ), 384, y, 12, 255 );
		}
		
		//
		DrawText( "㉺L[œՓx̑IAEL[ŃLN^[̑I", 40, 420, 12, 255 );
		DrawText( "VbgL[Ńy[WA{L[Ńj[֖߂",   40, 440, 12, 255 );
	}
}

/**
 * Ugʐp̃L[`FbN
 */
function ResultKeyCheck(){
	//L[
	if( GetKeyState( VK_SHOT ) == KEY_PUSH ){
		if( ResultMode == 1 ){
			//XyJֈړ
			ResultMode = 2;
		}else if( ResultMode == 2 ){
			//y[W
			SpellResultPage += 1;
			
			//ŏIy[W܂ōsnCXRAʂ֖߂
			if( SpellResultPage >= SpellResultMaxPage ){
				SpellResultPage = 0;
				ResultMode = 1;
			}
		}
	}
	//L[
	if( GetKeyState( VK_UP ) == KEY_PUSH ){
		ShowPlayerIndex -= 1;
		if( ShowPlayerIndex < 0 ){
			ShowPlayerIndex = 2;
		}
	}
	//L[
	if( GetKeyState( VK_DOWN ) == KEY_PUSH ){
		ShowPlayerIndex += 1;
		if( ShowPlayerIndex > 2 ){
			ShowPlayerIndex = 0;
		}
	}
	//L[
	if( GetKeyState( VK_LEFT ) == KEY_PUSH ){
		ShowDifficultIndex -= 1;
		if( ShowDifficultIndex < 0 ){
			ShowDifficultIndex = 2;
		}
	}
	//EL[
	if( GetKeyState( VK_RIGHT ) == KEY_PUSH ){
		ShowDifficultIndex += 1;
		if( ShowDifficultIndex > 2 ){
			ShowDifficultIndex = 0;
		}
	}
	
	ShowPlayer = ShowPlayers[ ShowPlayerIndex ];
	ShowDifficult = ShowDifficults[ ShowDifficultIndex ];
}